package com.example.appointment.repository;

import com.example.appointment.entity.ClubActivity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 社团活动数据访问接口
 */
@Repository
public interface ClubActivityRepository extends JpaRepository<ClubActivity, Long> {
    
    /**
     * 查找活跃的活动列表
     */
    Page<ClubActivity> findByIsActiveTrue(Pageable pageable);
    
    /**
     * 查找即将开始的活动（活跃且未过期）
     */
    Page<ClubActivity> findByIsActiveTrueAndEndTimeAfter(LocalDateTime now, Pageable pageable);
    
    /**
     * 根据标题或描述模糊搜索活动
     */
    Page<ClubActivity> findByIsActiveTrueAndTitleContainingOrDescriptionContaining(
            String titleKeyword, String descriptionKeyword, Pageable pageable);
    
    /**
     * 查找用户创建的活动
     */
    List<ClubActivity> findByCreatedById(Long userId);
} 